<template>
	<el-main>
			<div style="text-align: center;font-weight: 600;font-size: 16px">
				{{ form.newsTitle }}
			</div>
		<el-main>
			<span v-html="form.content"></span>
			<div style="margin-top: 20px;text-align: right;">
				<div style="float: left;">
					【{{ form.newsTypeName }}】{{ form.createUser }}
				</div>
				<span>点击：{{ form.onclickCount }}次</span><span style="margin-left: 20px">发布时间：{{ form.createTime }}</span>
			</div>
		</el-main>
	</el-main>
</template>
<script>
export default {
	name: 'News Details',
	data() {
		return {
			form: {
				newsId: this.$route.query.newsId,
				createUser: '',
				newsTitle: '',
				newsTypeName: '',
				onclickCount: 0,
				content: '',
				createTime: '',
			},
		}
	},
	mounted() {
		this.getMyNewsById();
	},
	methods: {
		async setNewsReadStatus() {
			await this.$API.info.news.setNewsReadStatus.post({newsId: this.form.newsId});
		},
		async getMyNewsById() {
			let res = await this.$API.info.news.getMyNewsById.get({newsId: this.form.newsId});
			{
				if (res.code == 200) {
					this.form.createUser = res.data.createUser
					this.form.newsTypeName = res.data.newsTypeName
					this.form.newsType = res.data.newsType
					this.form.content = res.data.content
					this.form.newsTitle = res.data.newsTitle
					this.form.onclickCount = res.data.onclickCount
					this.form.createTime = res.data.createTime
					this.setNewsReadStatus();
				} else {
					this.$alert(res.message, "提示", {type: 'error'})
				}
			}
		}
	}

}
</script>

<style>
</style>
